﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace Libcs
{
    class Dllvc
    {
        [DllImport("libdll.dll")]
        static extern unsafe int Daq_Start();
        [DllImport("libdll.dll")]
        static extern unsafe void Daq_Set(int gain, int trimode, int clkmode, int samrate);
        [DllImport("libdll.dll")]
        static extern unsafe int Daq_Get(int maxlen, double* buf);
        [DllImport("libdll.dll")]
        public static extern unsafe int Daq_Getchs(double* buf2);
        [DllImport("libdll.dll")]
        public static extern unsafe int dll_Test(int i);

        bool daqrun = false;

        public void test()
        {
            dll_Test(1);
        }

        public unsafe int Daqget(double[] data, int minlen, int maxlen)
        {
            int t = -1;

            fixed (double* dbuf = data)
            {
                while (daqrun)
                {
                    t = Daq_Get(maxlen, dbuf);
                }

                //daqrun = false;
            }
            if (daqrun == false)
                t = -2;

            return t;
        }
    }
}
